# a = [66.25,333,333,1,1234.5]

# print(a.count(333),a.count(66.25),a.count('x'))

# a.insert(2,-1)
# a.append(333)
# print(a)
# print(a.index(333))
# a.remove(333)
# print(a)
# a.reverse
# print(a)

# a.sort()
# print(a)

#1、创建一个空栈
# stack = []

# #2、压入（push）操作
# stack.append(1)
# stack.append(2)
# stack.append(3)

# print(stack)
# # 3、弹出（Pop）操作
# top_element = stack.pop()
# print(top_element)
# print(stack)
# # 4、查看栈顶元素（Peek/Top）
# top_element = stack[-1]
# print(top_element)
# # 5、检查是否为空（isEmpty）
# is_empty = len(stack) == 0
# print(is_empty)

# # 6、获取栈的大小（Size）
# size = len(stack)
# print(size)

# class Stack:
#       def __init__(self):
#             self.stack = []

#       # 添加元素
#       def push(self,item):
#             self.stack.append(item)

#       def pop(self):
#             if not self.is_empty():
#                   return self.stack.pop()
#             else:
#                   raise IndexError("pop from empty stack")
            
#       def peek(self):
#             if not self.is_empty():
#                   return self.stack[-1]
#             else:
#                   raise IndexError("peek from empty stack")
            
#       def is_empty(self):
#             return len(self.stack) == 0
      
#       def size(self):
#             return len(self.stack)
      
# stack = Stack()
# stack.push(1)
# stack.push(2)
# stack.push(3)

# print("栈顶元素：",stack.peek())
# print("栈大小：",stack.size())

# print("弹出元素：",stack.pop())
# print("栈是否为空：",stack.is_empty())
# print("栈大小：",stack.size)


# from collections import deque

# queue = deque()

# queue.append('a')
# queue.append('b')
# queue.append('c')

# print("队列状态：",queue) # 输出：队列状态：deque(['a','b','c'])

# # 从对首移除元素
# first_element = queue.popleft()
# print("移除的元素：",first_element)
# print("队列状态：",queue)

# is_empty = len(queue) == 0
# print("队列是否为空：",is_empty)

# size = len(queue)
# print("队列大小：",size)

# class Queue:
#       def __init__(self):
#             self.queue = []

#       def enqueue(self,item):
#             self.queue.append(item)

#       def dequeue(self):
#             if not self.is_empty():
#                   return self.queue.pop(0)
#             else:
#                   raise IndexError("dequeue from empty queue")
            
#       def peek(self):
#             if not self.is_empty():
#                   return self.queue[0]
#             else:
#                   raise IndexError("peek from empty queue")
            
#       def is_empty(self):
#             return len(self.queue) == 0
      
#       def size(self):
#             return len(self.queue)
      
# queue = Queue()

# queue.enqueue('a')
# queue.enqueue('b')
# queue.enqueue('c')

# print("队首元素：",queue.peek())
# print("队列大小：",queue.size())

# print("移除的元素：",queue.dequeue())
# print("队列是否为空：",queue.is_empty())
# print("队列大小：",queue.size())

# vec = [2,4,6]
# ve = [3*x for x in vec]
# print(ve)

# ve = [[x,x*2] for x in vec]
# print(ve)

# freshfruit = [' banana',' loganberry','passion fruit ']
# fruit = [weapon.strip() for weapon in freshfruit]
# print(fruit)

# ve = [3*x for x in vec if x > 3]
# print(ve)
# v = [3*x for x in vec if x < 2]
# print(v)

# vec1 = [2,4,6]
# vec2 = [4,3,-9]

# ve1 = [x*y for x in vec1 for y in vec2]
# print(ve1)

# ve11 = [x+y for x in vec1 for y in vec2]
# print(ve11)

# ve12 =  [vec1[i]*vec2[i] for i in range(len(vec1))]
# print(ve12)

# list = [str(round(355/113,i)) for i in range(1,6)]
# print(list)

# matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12],]

# list1 = [[row[i] for row in matrix] for i in range(4)]
# print(list1)

# transposed = []
# for i in range(4):
#       transposed.append([row[i] for row in matrix])

# print(transposed)

# a = [-1,1,66.25,333,333,1234.5]
# del a[0]
# print(a)
# del函数
# del a[2:4]
# print(a)

# del a[:]
# print(a)
# 元组和序列
# t = 12345,54321,'hello!'
# print(t[0])

# u = t,(1,2,3,4,5)
# print(u)
# 集合
# basket = {'apple','orange','apple','pear','orange','banana'}
# print(basket)
# print('orange' in basket)
# print('crabgrass' in basket)

# a = set('abracadabra')
# b = set('alacazam')

# print(a)

# print(a-b)

# print(a | b)

# print(a & b)

# print(a ^ b)

# a = {x for x in 'abracadabra' if x not in 'abc'}
# print(a)

# 字典
# tel = {'jack':4098,'sape':4139}
# tel['guido'] = 4127
# print(tel)

# print(tel['jack'])

# del tel['sape']

# tel['irv'] = 4127

# print(tel)

# print(list(tel.keys()))
# print(sorted(tel.keys()))
# print('guido' in tel)
# print('jack' not in tel)

# mydict = dict([('sape',4139),('guido',4127),('jack',4098)])
# print(mydict)

# mydi = {x:x**2 for x in (2,4,6)}
# print(mydi)

# mydic = dict(sape=4139,guido=4127,jack=4098)
# print(mydic)

# 遍历技巧
knights = {'gallahad':'the pure','robin':'the brave'}
for k, v in knights.items():
      print(k,v)


